package com.tencent.sr.iris.activity.service.activity;

import com.tencent.sr.bizmid.user.core.interfaces.dto.UserCoreDTO;
import com.tencent.sr.iris.activity.dependency.dto.data.CommissionInfoDTO;
import com.tencent.sr.iris.activity.domain.event.dto.ActivityTaskDTO;
import com.tencent.sr.iris.activity.domain.event.dto.InviteLimitDTO;
import com.tencent.sr.iris.activity.domain.event.dto.SpecialOldTttResultDTO;
import com.tencent.sr.iris.activity.interfaces.dto.AwardInfoDTO;
import com.tencent.sr.iris.activity.interfaces.request.task.UserAwardInfoRequest;
import com.tencent.sr.iris.activity.interfaces.response.activity.QueryAwardReceiveListResponse;
import com.tencent.sr.iris.activity.interfaces.response.activity.UserAwardInfoResponse;
import com.tencent.sr.iris.activity.interfaces.response.group.task.FirstOrderInfoRes;
import com.tencent.sr.iris.activity.repository.entity.TIrisActivityAwardRecordDO;
import com.tencent.sr.iris.activity.repository.entity.TIrisUserTaskRecordDO;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface ActivityCommonService {

    UserAwardInfoResponse getAwardInfo(UserAwardInfoRequest request);

    AwardInfoDTO getAwardInfoByMarket(String info);

    /**
     * 根据award_info字段查询权益信息，缓存一分钟
     *
     * @param info
     * @return
     */
    AwardInfoDTO getAwardInfoCacheByMarket(String info);

    AwardInfoDTO getAwardInfo(String info);

    /**
     * 查询佣金和有效分享数
     *
     * @param uid
     * @param startTime
     * @param endTime
     * @return
     */
    CommissionInfoDTO queryCommissionInfo(String uid, String startTime, String endTime);

    /**
     * 上级发送权益
     *
     * @param userTaskRecordDO
     * @param task
     */
    TIrisActivityAwardRecordDO sendAwardForSupervisor(TIrisUserTaskRecordDO userTaskRecordDO, ActivityTaskDTO task);

    /**
     * 自己发送权益
     *
     * @param userTaskRecordDO
     * @param task
     */
    TIrisActivityAwardRecordDO sendAward(TIrisUserTaskRecordDO userTaskRecordDO, ActivityTaskDTO task);

    /**
     * 查询发奖对应的任务记录
     * @param uid
     * @param taskBizId
     * @return
     */
    TIrisUserTaskRecordDO queryAwardTaskRecordInfo(String uid, String taskBizId);

    TIrisActivityAwardRecordDO buildAwardRecordDO(TIrisUserTaskRecordDO userTaskRecordDO,
                                                  ActivityTaskDTO task, String awardUid, String outTradeNo);

    /**
     * 查询成为见习会员时间
     *
     * @param uid
     * @return
     */
    Long queryTraineeTime(String uid);

    /**
     * 查询邀请有礼策略切换时间
     *
     * @param uid
     * @return
     */
    Long queryInviteChangeTime(String uid);

    /**
     * 查询邀请有礼上限策略切换时间
     * @param uid
     * @return
     */
    Long queryInviteUpperLimitChangeTime(String uid);

    /**
     * 处理老团推团并存入缓存
     *
     * @param uid
     * @return
     */
    SpecialOldTttResultDTO handleSpecialOldTttCache(String uid, long eventTime);

    /**
     * 处理老团推团
     *
     * @param uid
     * @return
     */
    SpecialOldTttResultDTO handleSpecialOldTtt(String uid, long eventTime);


    /**
     * 根据外部单号查询中奖列表
     *
     * @param outTradeNoList
     * @return
     */
    List<QueryAwardReceiveListResponse> queryAwardReceiveList(List<String> outTradeNoList);

    /**
     * 根据等级获取限额
     *
     * @param level
     * @param uid
     * @return
     */
    Integer getLevelInviteLimit(String level, String uid);

    /**
     * 查询用户的邀请有礼限额
     *
     * @param uid
     * @param becomeTraineeTime
     * @return
     */
    InviteLimitDTO queryInviteLimit(String uid, Long becomeTraineeTime);

    /**
     * 查询用户的邀请有礼限额
     *
     * @param uid
     * @param monthStr
     * @return
     */
    InviteLimitDTO queryUserInviteLimit(String uid, String monthStr);

    /**
     * 查询用户自购gmv和佣金信息
     *
     * @param uid
     * @param startTime
     * @param endTime
     * @return
     */
    CommissionInfoDTO queryCommissionAndSelfBuyGMVInfo(String uid, String startTime, String endTime);

    /**
     * 查询首单信息
     * @param uid
     * @param startTime
     * @param endTime
     * @param firstOrder
     * @return
     */
    CommissionInfoDTO queryInviteTaskTarget(String uid, String startTime, String endTime, boolean firstOrder);

    /**
     * 查询首单信息
     * @param uid
     * @param startTime
     * @param endTime
     * @return
     */
    FirstOrderInfoRes firstOrderInfo(String uid, String startTime, String endTime);

    /**
     * 查询用户自购gmv
     *
     * @param uid
     * @param startTime
     * @param endTime
     * @return
     */
    Integer querySelfBuyGMVInfo(String uid, String startTime, String endTime);

    /**
     * 查询上级的邀请限额
     * @param uidList
     * @param dateList
     * @return
     */
    Map<String, Map<String, Integer>> queryInviteLimitMap(List<String> uidList, List<Date> dateList);

    /**
     * 获取预估收益-通过activityId和taskId缓存
     *
     * @param request
     * @return
     */
    UserAwardInfoResponse getAwardInfoByActivityAndTask(UserAwardInfoRequest request);


    /**
     * 根据派奖查询用户的邀请有礼限额
     * @param pid
     * @param becomeTraineeTime
     * @return
     */
    InviteLimitDTO queryInviteLimitByAward(String pid, Long becomeTraineeTime);
}
